package com.controller;

import com.domain.DTO.FlightClassDto;
import com.domain.VO.FlightClassVO;
import com.service.IFlightClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import com.common.result.ResponseResultAdvice;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * @author 大忽悠
 * @create 2022/9/15 11:09
 */
@Validated
@RestController
@RequestMapping("/flightClass")
@RequiredArgsConstructor
@ResponseResultAdvice
@Api(tags = "班次请求")
public class FlightClassController {
    private final IFlightClassService iFlightClassService;

    @ApiOperation("添加班次")
    @PostMapping
    public void addFlightClass(FlightClassVO flightClassVO) {
            iFlightClassService.save(flightClassVO);
    }

    @ApiOperation("删除班次")
    @DeleteMapping
    public void removeFlightClass(@RequestParam("id")Integer id) {
        iFlightClassService.removeById(id);
    }

    @ApiOperation("根据航班id查询班次信息")
    @GetMapping("/list")
    public List<FlightClassDto> listFlightClass(@RequestParam("flightId")Integer flightId){
          return iFlightClassService.list(flightId);
    }
}
